import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import { setupStore } from '@/store'
import { useI18n } from '@/plugins/i18n'
import { useElementPlus } from '@/plugins/element-plus'
import { MotionPlugin } from '@vueuse/motion'
import { getPlatformConfig } from './config'
import { injectResponsiveStorage } from './utils/responsive'

// 引入重置样式
import './style/reset.scss'
// 导入公共样式
import './style/index.scss'
// 引入字体样式
import './assets/icon/icon.css'
// 一定要在main.ts中导入tailwind.css，防止vite每次hmr都会请求src/style/index.scss整体css文件导致热更新慢的问题
import './style/tailwind.css'
import 'element-plus/dist/index.css'

const app = createApp(App)

// 全局注册vue-tippy
import 'tippy.js/dist/tippy.css'
import 'tippy.js/themes/light.css'
import VueTippy from 'vue-tippy'
// 全局注册按钮权限指令
import BtnAuth from '@/utils/auth'
app.use(VueTippy, {
  defaultProps: {
    placement: 'right'
  }
})
app.use(BtnAuth)

getPlatformConfig(app).then(async config => {
  setupStore(app)
  app.use(router)
  await router.isReady()
  injectResponsiveStorage(app, config)
  app.use(MotionPlugin).use(useI18n).use(useElementPlus)
  app.mount('#app')
})
